Implement nexus-based activity cancels#2917
Merged
Merged
Conversation
c1d83e5 to
a4c9a5a
Compare
935e645 to
22ea206
Compare
cd6d9c1 to
487f99f
Compare
487f99f to
8b0202b
Compare
maciejdudko
requested changes
Jun 23, 2026
8b0202b to
c5ab593
Compare
maciejdudko
approved these changes
Jun 23, 2026
maciejdudko
left a comment
Contributor
There was a problem hiding this comment.
One nit, otherwise looks great! LGTM!
Comment on lines
+27
to
+36
| CompletableFuture<Void> result = new CompletableFuture<>(); | ||
| cancellationFuture.whenComplete( | ||
| (ignored, exception) -> { | ||
| if (exception == null) { | ||
| result.complete(null); | ||
| } else { | ||
| result.completeExceptionally(unwrapCompletionException(exception)); | ||
| } | ||
| }); | ||
| return result; |
Contributor
There was a problem hiding this comment.
Nit: this can be simplified:
Suggested change
| CompletableFuture<Void> result = new CompletableFuture<>(); | |
| cancellationFuture.whenComplete( | |
| (ignored, exception) -> { | |
| if (exception == null) { | |
| result.complete(null); | |
| } else { | |
| result.completeExceptionally(unwrapCompletionException(exception)); | |
| } | |
| }); | |
| return result; | |
| return cancellationFuture.exceptionally(e -> throw unwrapCompletionException(e)); |
This will return a new dependent future on each call, so calling complete() on it won't mess up token's internal state.
Member
Author
There was a problem hiding this comment.
Doesn't actually work since the unwrapped exception is checked unfortunately. End up needing to change the unwrapper to be just as long as this more or less.
Comment on lines
+62
to
+65
| public ActivityCancellationToken getCancellationToken() { | ||
| throw new UnsupportedOperationException( | ||
| "getCancellationToken is not supported for local activities"); | ||
| } |
Contributor
There was a problem hiding this comment.
It does make it harder to write an activity that works in both local and non-local context, though. But we can revisit it another time - throwing exception leaves the door open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was changed
ActivityCancellationTokento the activity context help with thisWhy?
Parity, improved experience, no need to heartbeat if there are no details to record.
Checklist
Closes
How was this tested:
Added tests
Any docs updates needed?